<template>
  <el-form v-bind="$attrs" :model="value">
    <template v-for="item in formItemList">
      <template v-if="getValue(item)">
        <custom-form-item
          :key="item['prop']"
          v-model="value[item['prop']]"
          v-bind="item"
        ></custom-form-item>
      </template>
    </template>
    <slot name="footer"></slot>
  </el-form>
</template>

<script>
import customFormItem from "./customFormItem";
export default {
  props: {
    value: {
      type: Object,
      required: true,
    },
    formItemList: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  components: { customFormItem },
  data() {
    return {
    };
  },
  methods: {
    getValue(val) {
      if (val.show) {
        let firstArr = val.show.split("&");
        return firstArr.every((item) => {
          let temp = item.split("=");
          return this.value[temp[0]] == temp[1];
        });
      }
      return true;
    },
  },
};
</script>
<style lang="scss" scoped></style>
